package de.ur.iw.wiki;

import java.util.HashMap;

public class Settings {
	
	
	public static final double DEFAULT_PATH_LENGTH = 10;

	// Wiki Settings
	/**
	 * the additional weight for categories in percentage
	 */
	public static final int KEY_CATEGORIES_WEIGHT = 0;
	/**
	 * whether to use files or not
	 */
	public static final int KEY_FILES = 1;
	/**
	 * whether to limit paths to categories or not
	 */
	public static final int KEY_LIMIT_TO_CATEGORIES = 2;
	/**
	 * whether to prevent loops or not
	 */
	public static final int KEY_PREVENT_LOOPS = 4;
	/**
	 * whether to prevent dead ends or not
	 */
	public static final int KEY_DEAD_END = 5;
	/**
	 * the maximum number of steps taken
	 */
	public static final int KEY_LIMITED_STEPS = 6;
	/**
	 * the maximum number of paths running parallel
	 */
	public static final int KEY_MAX_PATHS_VALUE = 12;
	/**
	 * the page to start at
	 */
	public static final int KEY_START_PAGE = 19;
	/**
	 * the location of the result php page
	 */
	public static final int KEY_RESULT_LOCATION = 20;
	/**
	 * the key to open the results page
	 */
	public static final int KEY_OPEN_RESULTS = 21;
	
	public static final int KEY_WEIGHT_OF_FIRST_PARAGRAPHS = 13;
	public static final int KEY_WEIGHT_OF_MIDDLE_PARAGRAPHS = 14;
	public static final int KEY_WEIGHT_OF_LAST_PARAGRAPHS = 15;
	public static final int KEY_WEIGHT_OF_FIRST_LINKS = 16;
	public static final int KEY_WEIGHT_OF_MIDDLE_LINKS = 17;
	public static final int KEY_WEIGHT_OF_LAST_LINKS = 18;

	// Database Settings
	public static final int KEY_DATABASE_LOCATION = 7;
	public static final int KEY_DATABASE_NAME = 8;
	public static final int KEY_DATABASE_TABLENAME = 9;
	public static final int KEY_DATABASE_USERNAME = 10;
	public static final int KEY_DATABASE_PASSWORD = 11;

	// Randomwalk Keys
	public static final int KEY_RANDOMWALK_START = 13;

	private static HashMap<Integer, Boolean> boolSettings = new HashMap<Integer, Boolean>();
	private static HashMap<Integer, Double> doubleSettings = new HashMap<Integer, Double>();
	private static HashMap<Integer, String> stringSettings = new HashMap<Integer, String>();

	public static void setKey(int key, boolean value) {
		boolSettings.put(key, value);
	}

	public static void setKey(int key, double value) {
		doubleSettings.put(key, value);
	}

	public static void setKey(int key, String value) {
		stringSettings.put(key, value);
	}

	public static boolean getBoolean(int key, boolean defaultValue) {
		Boolean result = boolSettings.get(key);
		if (result == null) {
			return defaultValue;
		} else {
			return result;
		}
	}

	public static double getDouble(int key, double defaultValue) {
		Double result = doubleSettings.get(key);
		if (result == null) {
			return defaultValue;
		} else {
			return result;
		}
	}

	public static String getString(int key, String defaultValue) {
		String result = stringSettings.get(key);
		if (result == null) {
			return defaultValue;
		} else {
			return result;
		}
	}

}
